<?php

namespace WoXuanWang\MemberOrder\Models;

use Eloquent as Model;

/**
 * Class MemberOrder
 * @package WoXuanWang\MemberOrder\Models
 * @version April 6, 2017, 7:06 pm CST
 */
class MemberOrder extends Model
{

    public $table = 'member_orders';
    


    public $fillable = [
        'user_id',
        'amount',
        'status',
        'start_at',
        'end_at'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'user_id' => 'integer',
        'status' => 'integer',
        'start_at' => 'date',
        'end_at' => 'date'
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'amount' => 'required'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     **/
    public function user()
    {
        return $this->belongsTo(\WoXuanWang\User\Models\User::class, 'user_id', 'id');
    }
}
